﻿using Windows.Data.Json;

namespace XiaoweiV2.ResponseDataTypes
{
    class NewsBasic : IDataType
    {
        private const string UrlKey = "content_url";
        private const string HasAudioKey = "has_audio";
        private const string IdKey = "id";
        private const string PictureKey = "pic_url";
        private const string PublishTimeKey = "publish_time";
        private const string SourceKey = "source";
        private const string SummaryKey = "summary";
        private const string TitleKey = "title";

        public string Url { get; set; }

        public bool HasAudio { get; set; }

        public string Id { get; set; }

        public string ImageUrl { get; set; }

        public string PublishTime { get; set; }

        public string Source { get; set; }

        public string Summary { get; set; }

        public string Title { get; set; }

        public string Content { get; set; }

        public void FromJson(JsonObject json)
        {
            Url         = json.GetNamedString(UrlKey, "");
            HasAudio    = json.GetNamedBoolean(HasAudioKey, false);
            Id          = json.GetNamedString(IdKey, "");
            ImageUrl    = json.GetNamedString(PictureKey, "");
            PublishTime = json.GetNamedString(PublishTimeKey, "");
            Source      = json.GetNamedString(SourceKey, "");
            Summary     = json.GetNamedString(SummaryKey, "");
            Title       = json.GetNamedString(TitleKey, "");
            if (string.IsNullOrEmpty(Url))
            {
                Url = "http://a";
            }
        }
        public JsonObject ToJson()
        {
            return null;
        }
    }
}
